import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('system.approvalManagement.fields');
const { t: common } = useI18n('common');
const approvalManagementFields = {
  type: t('type'),
  auto: t('auto'),
  approver: t('approver'),
  inOrder: t('inOrder'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: approvalManagementFields.type,
    align: 'center',
    dataIndex: 'type',
    customRender: ({ text }) => {
      return render.renderDict(text, 'approvalType');
    },
  },
  {
    title: approvalManagementFields.auto,
    align: 'center',
    dataIndex: 'auto',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [
        { text: common('yes'), value: 'Y' },
        { text: common('no'), value: 'N' },
      ]);
    },
  },
  {
    title: approvalManagementFields.approver,
    align: 'center',
    dataIndex: 'approver_dictText',
  },
  {
    title: approvalManagementFields.inOrder,
    align: 'center',
    dataIndex: 'inOrder',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [
        { text: common('yes'), value: 'Y' },
        { text: common('no'), value: 'N' },
      ]);
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: approvalManagementFields.type,
  //   field: 'type',
  //   component: 'Input',
  // },
  {
    label: approvalManagementFields.auto,
    field: 'auto',
    component: 'JSwitch',
    componentProps: {},
  },
  {
    label: approvalManagementFields.approver,
    field: 'approver',
    component: 'JSelectUserByDept',
    componentProps: {
      labelKey: 'realname',
    },
  },
  {
    label: approvalManagementFields.inOrder,
    field: 'inOrder',
    component: 'JSwitch',
    componentProps: {},
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
